#include "ITestNativeService.h"

namespace android {

class BpTestNativeService: public BpInterface<ITestNativeService>
{
public:
    BpTestNativeService(const sp<IBinder>& impl)
        : BpInterface<ITestNativeService>(impl)
    {
    }

    virtual int verify()
    {
        Parcel data, reply;
        remote()->transact(BnTestNativeService::TRANSACTION_verify, data, &reply);
        return reply.readInt32();
    }
};

// declare TestNativeService with aidl file in java
IMPLEMENT_META_INTERFACE(TestNativeService, "com.freeme.internal.server.ITestNativeService");

// ----------------------------------------------------------------------------

status_t BnTestNativeService::onTransact(
        uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags)
{
    ALOGV("TestNativeService, OnTransact (%u,%u)", code, flags);

    Mutex::Autolock _l(mLock);

    switch(code) {
        case TRANSACTION_verify:
            data.enforceInterface(descriptor);
            reply->writeInt32(verify());
            return NO_ERROR;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}

// ----------------------------------------------------------------------------

}; // namespace android
